/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package inferenceEngine.types;


import inferenceEngine.labels.Label;

import org.dom4j.Element;

/**
 *
 * @author Boshi Li
 */
public class Meaning {
	private Label label = null;
	private String meaning = null;
    
	public Meaning( Element e ){
		label = new Label( e.attribute("label").getValue() );
		if( e.attribute("mean")!=null ){
			meaning = e.attribute("mean").getValue();
		}
	}
	
	/**
	 * fire the rule
	 * @return the meaning of the label 
	 */
	public String fire(){
		return meaning;
	}
	
	/**
	 * 
	 * @param label
	 * @return if the rule can be fired 
	 */
	public boolean match( Label label ){
		return this.label.equals( label );
	}
	
	public Label getLabel(){
		return label;
	}
	
	@Override
	public int hashCode(){
		return label.hashCode();
	}
	
	@Override
	public String toString(){
		return String.format("%s means '%s'", label, meaning );
	}
}
